template<class T>
class node {
public:
    node(T val = 0) : value(val), prev(NULL), next(NULL) {}
    void set_value(T val) { value = val; }
    T get_value() const { return value; }
    node<T>* get_prev() const { return prev; }
    node<T>* get_next() const { return next; }
    void insert(node<T>* new_node) {
        new_node->prev = prev;
        new_node->next = this;
        if (prev != NULL) prev->next = new_node;
        prev = new_node;
    }
private:
    T value;
    node<T>* prev;
    node<T>* next;
};